﻿using System;

class PositiveIntegerInAString
{
    static void Main()
    {
        //Exercise 6.
        //You are given a sequence of positive integer values written into a string, separated by spaces. Write a function that 
        //reads these values from given string and calculates their sum. 
        //Example: 		string = "43 68 9 23 318" ->  result = 461

        //string sequence = "43 68 9 23 318";
        //string[] sequenceStr = sequence.Split(' ');

        Console.Write("Enter a sequence of positive integer values, separated by spaces: ");
        string[] sequenceStr = Console.ReadLine().Split(' ');

        int result = 0;
        for (int i = 0; i < sequenceStr.Length; i++)
        {
            result = result + int.Parse(sequenceStr[i]);
        }
        Console.WriteLine("The result is: {0}", result);
    }
}

